package com.gxuwz.service;

import com.gxuwz.mapper.CourseMapper;
import com.gxuwz.model.entity.Course;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseService {

    @Autowired
    private CourseMapper courseMapper;

    // 根据 courseID 查询课程
    public Course getCourseByCourseID(String courseID) {
        return courseMapper.selectCourseByCourseID(courseID);
    }

    // 根据 courseName 查询课程
    public Course getCourseByCourseName(String courseName) {
        return courseMapper.selectCourseByCourseName(courseName);
    }

    // 更新课程信息
    public boolean updateCourse(Course course) {
        return courseMapper.updateCourse(course) > 0;
    }

    // 添加新的课程
    public boolean addCourse(Course course) {
        return courseMapper.insertCourse(course) > 0;
    }

    // 根据 courseID 删除课程
    public boolean deleteCourseByCourseID(String courseID) {
        return courseMapper.deleteCourseByCourseID(courseID) > 0;
    }

    // 查询所有课程
    public List<Course> getAllCourses() {
        return courseMapper.getAllCourse();
    }
}
